package com.javaee.term.utils;
import java.util.Random;

/**
 * Created by jon
 */
public class KeyUtil {

    /**
     * 生成唯一的主键
     * 格式: 时间+随机数
     * @return
     */
    public static synchronized String genUniqueKey() {
        Random random = new Random();
        Integer number = random.nextInt(900000) + 100000;

      String key= System.currentTimeMillis() + String.valueOf(number);
      return key.substring(3);
    }
    public static synchronized Integer getUniqueKey() {
        Random random = new Random();
        Integer number = random.nextInt(90000000) + 10000000;
        return number;
    }

}
